#include <gtest/gtest.h>
#include "core/acs_request.h"

using namespace aliyun;

class TestAcsRequest : public AcsRequest {
public:
  TestAcsRequest(const string& product, const string& version, const string& action) : AcsRequest(product, version, action) {
  }
  virtual ~TestAcsRequest() {}
  virtual string ComposeUrl(ISigner *i_signer, const Credential* credential, const string& domain) {
    return "";
  }
};

TEST(core, AcsRequest) {
  TestAcsRequest acs_request("product", "version", "action");
  ASSERT_STREQ("version", acs_request.GetVersion().c_str());
  ASSERT_STREQ("product", acs_request.GetProduct().c_str());
  ASSERT_STREQ("action", acs_request.GetAction().c_str());
  acs_request.SetVersion("test.SetVersion");
  acs_request.SetProduct("test.SetProduct");
  acs_request.SetAction("test.SetAction");
  ASSERT_STREQ("test.SetVersion", acs_request.GetVersion().c_str());
  ASSERT_STREQ("test.SetProduct", acs_request.GetProduct().c_str());
  ASSERT_STREQ("test.SetAction", acs_request.GetAction().c_str());

  acs_request.SetAcceptFormat("test.SetAcceptFormat");
  ASSERT_STREQ("test.SetAcceptFormat", acs_request.GetAcceptFormat().c_str());

  ASSERT_EQ(acs_request.GetQueryParameters().size(), (size_t)0);
  ASSERT_EQ(acs_request.GetHeaders().size(), (size_t)1); // in construct, has insert "x-sdk-client: cpp/1.0.0"

  acs_request.SetMethod("test.SetMethod");
  ASSERT_STREQ("test.SetMethod", acs_request.GetMethod().c_str());

  acs_request.SetProtocol("test.SetProtocol");
  ASSERT_STREQ("test.SetProtocol", acs_request.GetProtocol().c_str());

  acs_request.SetRegionId("test.SetRegionId");
  ASSERT_STREQ("test.SetRegionId", acs_request.GetRegionId().c_str());
}

// end of file
